import sys
import os
from datetime import datetime
# 添加项目根目录到 Python 路径
sys.path.append(os.path.abspath("../"))

from include import para    
from include import dataBase
from include import dealDate
from include import dealCode
from include import dealHistory
from include import dealMarket

if __name__ == '__main__':
    connect = dataBase.dataBaseConnect("../../../dataBaseConfig.json")
    dealCodeTest = dealCode.dealCode(connect)
    dealDateTest = dealDate.dealDate(connect)
    dealHistoryTest = dealHistory.dealHistory(connect)
    dealMarketTest = dealMarket.dealMarket(connect,dealDateTest,dealCodeTest,dealHistoryTest)

    if 1:
        print("isList 测试")
        print("2020-01-01,000001 是否存在")
        print(dealMarketTest.isList(datetime.strptime("2020-01-01", "%Y-%m-%d").date()  ,"000001"))
        print("1020-01-01,000001 是否存在")
        print(dealMarketTest.isList(datetime.strptime("1020-01-01", "%Y-%m-%d").date()  ,"000001"))
        print("2020-01-01,100001 是否存在")
        print(dealMarketTest.isList(datetime.strptime("1020-01-01", "%Y-%m-%d").date()  ,"100001"))

    if 1:
        print("isNewest 测试")
        print("2020-01-01,000001 是否更新")
        print(dealMarketTest.isNewest(datetime.strptime("2020-01-01", "%Y-%m-%d").date()  ,"000001"))
        print("1020-01-01,000001 是否更新")
        print(dealMarketTest.isNewest(datetime.strptime("1020-01-01", "%Y-%m-%d").date()  ,"000001"))
        print("2020-01-01,100001 是否更新")
        print(dealMarketTest.isNewest(datetime.strptime("1020-01-01", "%Y-%m-%d").date()  ,"100001"))

    if 1:
        print("getMarketOne 测试")
        dealMarketTest.getMarketOne(datetime.strptime("2025-05-06","%Y-%m-%d").date())        
        # 目前没有做日期正确与否的判断，会使程序直接崩溃
        #dealMarketTest.getMarketOne("2025-05-37")

    if 1:
        print("getMarketAll 测试")
        #dealMarketTest.getMarketAll()

    connect.commit()





